﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;


public partial class MasterPage_MasterPage_EmpDetail : System.Web.UI.MasterPage
{
    private string _PicUrl = "";

    private string _PageName = "";

    private string _HelpHref = "";

    public void IntiBar()
    {


        TitleBarControl.PageName = PageName != "" ? PageName : "";
        TitleBarControl.PicUrl = PicUrl != "" ? PicUrl : "";
        TitleBarControl.HelpHref = HelpHref != "" ? HelpHref : "";



        TitleBarControl.IntiBar();


    }

    public string PicUrl
    {
        get
        {
            return _PicUrl;
        }
        set
        {
            _PicUrl = value;
        }
    }

    public string PageName
    {
        get
        {
            return _PageName;
        }
        set
        {
            _PageName = value;
        }
    }

    public string HelpHref
    {
        get
        {
            return _HelpHref;
        }
        set
        {
            _HelpHref = value;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            Bind();


        }
    }


    private void Bind()
    {


        //Hashtable HT = new Hashtable();
        //HT.Add("salary", "SalaryInfonew");
        //HT.Add("hr", "HrInfonew");
        //HT.Add("self", "PrivyInfonew");
        //HT.Add("emp", "IndividualInfonew");
        //HT.Add("record", "record");
        //HT.Add("contract", "contract");
        if (HoverId.Value != "")
        {
            HyperLink HY = ((HyperLink)this.FindControl(HoverId.Value));
            HY.CssClass = "OnHover";
        }
        try
        {
            if (Request["action"] != null)
            {
                if (Request["action"].ToString() == "add")
                {
                    MenuTabs.Visible = false;
                    //EmpProfile.NavigateUrl = "../Employees/EmployeesProfile.aspx?action=add";
                }
                else
                {

                    string mode = Server.UrlEncode(Request["mode"]).ToString();
                    string action = Request["action"].ToString();
                    string eid = Request["eid"].ToString();



                    string redurl = "mode=" + mode + "&action=" + action + "&eid=" + eid;
                    EmpProfile.NavigateUrl = "javascript:void(0)";
                    EmpProfile.Attributes.Add("onclick", "location.href='" + "../Employees/EmployeesProfile.aspx?" + redurl + "';return false;");

                    EmpContract.NavigateUrl = "javascript:void(0)";
                    EmpContract.Attributes.Add("onclick", "location.href='" + "../Employees/ContractDetail.aspx?" + redurl + "';return false;");

                    EmpRecord.NavigateUrl = "javascript:void(0)";
                    EmpRecord.Attributes.Add("onclick", "location.href='" + "../Employees/EmpRecordSelfList.aspx?" + redurl + "';return false;");

                    EmpMove.NavigateUrl = "javascript:void(0)";
                    EmpMove.Attributes.Add("onclick", "location.href='" + "../Employees/EmpMoveList.aspx?" + redurl + "';return false;");

                    EmpCertificate.NavigateUrl = "javascript:void(0)";
                    EmpCertificate.Attributes.Add("onclick", "location.href='" + "../Employees/EmpCertificate.aspx?" + redurl + "';return false;");

                    EmpIssue.NavigateUrl = "javascript:void(0)";
                    EmpIssue.Attributes.Add("onclick", "location.href='" + "../Employees/EmpIssue.aspx?" + redurl + "';return false;");

                    EmpInsurance.NavigateUrl = "javascript:void(0)";
                    EmpInsurance.Attributes.Add("onclick", "location.href='" + "../Employees/EmpInsurance.aspx?" + redurl + "';return false;");

                    EmpYearHoliday.NavigateUrl = "javascript:void(0)";
                    EmpYearHoliday.Attributes.Add("onclick", "location.href='" + "../Employees/EmpYearHoliday.aspx?" + redurl + "';return false;");


                    EmpSalary.NavigateUrl = "javascript:void(0)";
                    EmpSalary.Attributes.Add("onclick", "location.href='" + "../EmployeesSalary/EmpSalaryAdjust.aspx?" + redurl + "';return false;");


                    EmpWorkExprience.NavigateUrl = "javascript:void(0)";
                    EmpWorkExprience.Attributes.Add("onclick", "location.href='" + "../Employees/EmpWorkExprienceList.aspx?" + redurl + "';return false;");


                    string[] md = Server.UrlDecode(mode).Split(',');


                    for (int i = 0; i < md.Length; i++)
                    {

                        switchVis(md[i].ToString());
                        //}
                    }

                    if (action == "edit")
                    {
                        if (Session["HrBack"] != null)
                        {
                            hidBackUrl.Value = Session["HrBack"].ToString();
                            Back.Visible = true;
                        }
                        else
                        {
                            Back.Visible = false;
                        }
                    }
                    else
                    {
                        Back.Visible = false;
                    }
                }
            }
            else
            {
                MenuTabs.Visible = false;
            }
        }
        catch
        {
            MenuTabs.Visible = false;
        }

    }

    private void switchVis(string value)
    {
        switch (value)
        {
            case "contract":
                contract.Visible = false;
                break;
            case "record":
                record.Visible = false;
                break;
            case "move":
                Move.Visible = false;
                break;
            case "certificate":
                Certificate.Visible = false;
                break;
            case "issue":
                Issue.Visible = false;
                break;
            case "insurance":
                Insurance.Visible = false;
                break;
            case "yearholiday":
                YearHoliday.Visible = false;
                break;
            case "salary":
                Salary.Visible = false;
                break;
            case "workexprience":
                WorkExprience.Visible = false;
                break;
            default:
                break;
        }
    }
    protected void EmpBack_Click(object sender, EventArgs e)
    {
        Response.Redirect(hidBackUrl.Value);
        Session["HrBack"] = hidBackUrl.Value;
    }
}
